import { Component, OnInit } from '@angular/core';
import { AuthService } from '../auth.service';

@Component({
  selector: 'app-account-assets',
  templateUrl: './account-assets.component.html',
  styleUrls: ['./account-assets.component.css']
})
export class AccountAssetsComponent implements OnInit {
  username: string = '';
  balance: number = 0;
  lockedBalance: number = 0;
  identity: string = '';

  constructor(private authService: AuthService) {}

  ngOnInit(): void {
    const accountInfo = this.authService.getAccountInfo();
    if (accountInfo) {
      this.username = accountInfo.username;
      this.balance = accountInfo.balance;
      this.lockedBalance = accountInfo.lockedBalance;
      this.identity = accountInfo.identity;
    }
  }

  recharge(): void {
    // 模拟充值逻辑
    const rechargeAmount = 500; // 假设充值金额为 500
    this.balance += rechargeAmount;
    alert(`充值成功！当前余额为：${this.balance}`);
  }
}
